package com.lezheba.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.log4j.Logger;

import com.lezheba.service.UserAdminService;

public class CalendarEventAction extends BaseAction {
	private static final long serialVersionUID = 1012329652723613183L;
	static Logger logger = Logger.getLogger(CalendarEventAction.class.getName());

	private UserAdminService service = new UserAdminService();

	private int dayth;

	private Date date = new Date();
	private String email;

	public String eventJson() throws Exception {
		String json = "[";
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Calendar a = Calendar.getInstance();
		a.setTime(date);
		a.set(Calendar.DATE, 1);// 把日期设置为当月第一天
		a.roll(Calendar.DATE, -1);// 日期回滚一天，也就是最后一天
		int MaxDate = a.get(Calendar.DATE);
		for (int i = 1; i <= MaxDate; i++) {
			a.set(Calendar.DATE, i);
			json += "{" + "title: " + "'第"+i+"天任务', start: '" + dateFormat.format(a.getTime()) +"'}";	
			if(i < MaxDate){
				json += ",";
			}
		}		
		json += "]";
		System.out.println(json);
		return super.ajax(json);

	}

	public static void main(String[] ds) {
		Date d = new Date();
		// DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.);
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

		// cal.set(GregorianCalendar.DAY_OF_MONTH, 1);
		Calendar a = Calendar.getInstance();
		a.setTime(d);
		a.set(Calendar.DATE, 1);// 把日期设置为当月第一天
		a.roll(Calendar.DATE, -1);// 日期回滚一天，也就是最后一天
		int MaxDate = a.get(Calendar.DATE);
		System.out.println("该月最大天数:" + MaxDate);
		System.out.println("该月最大天数:" + dateFormat.format(a.getTime()));

		a.set(Calendar.DATE, 2);

		System.out.println("该月最大天数:" + dateFormat.format(a));

	}

}
